import cgi,os,hashlib,math,urllib2

from google.appengine.api import memcache
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import *
from google.appengine.ext import db


class MainPage(webapp.RequestHandler):

	@login_required
	def get(self):		
		template_values = {					
			'other_html':'empty'
			}		
		path = os.path.join(os.path.dirname(__file__), 'index.html')
		self.response.out.write(template.render(path, template_values))
	
	def post(self):
		u = self.request.get('url') or ''
		f = urllib2.urlopen(u)
		u = f.read()
		template_values = {					
			'other_html':u
			}		
		path = os.path.join(os.path.dirname(__file__), 'index.html')
		self.response.out.write(template.render(path, template_values))

application = webapp.WSGIApplication(
                                     [('/', MainPage)],
                                     debug=False)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
